package com.shao.web.emp;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.shao.base.BaseServlet;
import com.shao.util.JdbcUtil;
import com.shao.util.Result;

public class EmployeeInsertServlet extends BaseServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String sql="insert into emp (empname,eage) values (?,?)";
		try {
			boolean update=JdbcUtil.update(sql,req.getParameter("empname"),req.getParameter("eage"));
			if(update){
				resp.getWriter().print(JSON.toJSONString(new Result(200,"success",null)));
			}else{
				resp.getWriter().print(JSON.toJSONString(new Result(401,"fail",null)));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	
	}

}
